package com.liuym.admin.controller;

import com.liuym.common.constants.GradeResponse;
import com.liuym.common.constants.RedisConstants;
import com.liuym.common.redis.RedisTemplateManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Liuym
 * @date 2019/4/16 9:20
 * @describe：
 */

@RestController
@RequestMapping("/admin/token")
public class DeleteTokenController {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @PostMapping("/deleteToken")
    public GradeResponse deleteToken(String token) {
        RedisTemplateManager redisTemplateManager = new RedisTemplateManager(redisTemplate);
        String value = redisTemplateManager.getValue(RedisConstants.ADMIN_LOGIN_USER_PREFIX + token);
        boolean b = redisTemplateManager.delKey(RedisConstants.ADMIN_LOGIN_USER_PREFIX + token);
        return GradeResponse.success();
    }
}
